﻿<%@ Page Title="" Language="C#" MasterPageFile="~/main.Master" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="comix.register" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
<script type="text/javascript">

    function checkTerms(source, arguments) {
        var accchb = document.getElementById('<%= chb_accept.ClientID %>')
        arguments.IsValid = accchb.checked;
    }

    function createProfileAjax(id) {
        if (Page_ClientValidate()) {
            var dt = "username=" + $("#<%= tb_mail.ClientID %>").val();
            dt += "&password=" + $("#<%= tb_password.ClientID %>").val();
            dt += "&firstname=" + $("#<%= tb_firstname.ClientID %>").val();
            dt += "&lastname=" + $("#<%= tb_lastname.ClientID %>").val();
            dt += "&address=" + $("#<%= tb_address.ClientID %>").val();
            dt += "&city=" + $("#<%= tb_city.ClientID %>").val();
            dt += "&tk=" + $("#<%= tb_tk.ClientID %>").val();
            dt += "&phone=" + $("#<%= tb_phone.ClientID %>").val();
            dt += "&countryid=" + $("#<%= DropDownList1.ClientID %>").val();
            dt += "&newsletter=" + $("#<%= chb_news.ClientID %>").is(':checked');
            // alert(dt);
            $.ajax({
                url: "createProfileAjax.ashx",
                type: "POST",
                data: dt,
                success: function (msg) { ShowResult(msg); },
                error: function (jqXHR, textStatus) { alert("Request failed: " + textStatus); }
            });

        }
        return false;
    }


    function ShowResult(msg) {
        if (msg == "OK")
            $.fancybox('<table class="mb" cellpadding="3" cellspacing="5"><tr><td>Ο λογαριασμός σας δημιουργήθηκε επιτυχώς.</td></tr><tr><td align="center"><a href="home.aspx">ΣΥΝΕΧΕΙΑ</a></td></tr></table>',
            { 'margin': 3, 'modal': true });
        else
            $.fancybox('<table class="mb" cellpadding="3" cellspacing="5"><tr><td align="center"><b>ΣΦΑΛΜΑ</b><tr><td>' + msg + '</td></tr><tr><td>Ο λογαριασμός σας ΔΕ δημιουργήθηκε</td></tr></table>',
            { 'margin': 3, 'modal': false });

    }


</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>ΔΗΜΙΟΥΡΓΙΑ ΛΟΓΑΡΙΑΣΜΟΥ</h1>
    
<table cellpadding="0" cellspacing="0" class="regtable">
<tr><td class="headerrow">ΑΝΑΓΝΩΡΙΣΤΙΚΑ ΧΡΗΣΤΗ</td></tr>
<tr><td align="left">
<table cellpadding="0" cellspacing="0" width="100%">
    <tr><td style="width:160px" class="fieldtitle">E-mail:</td><td class="fieldmain"><asp:TextBox ID="tb_mail" runat="server" CssClass="fieldtb"></asp:TextBox></td><td>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ErrorMessage="Παρακαλώ δώστε ένα έγκυρο e-mail" 
            ControlToValidate="tb_mail" Display="Dynamic" 
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
            ControlToValidate="tb_mail" Display="Dynamic" ErrorMessage="Υποχρεωτικό Πεδίο"></asp:RequiredFieldValidator>
        </td></tr>
    <tr><td style="width:160px" class="fieldtitle">Password:</td><td class="fieldmain"><asp:TextBox ID="tb_password" TextMode="Password" runat="server"  CssClass="fieldtb"></asp:TextBox></td><td>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ErrorMessage="Υποχρεωτικό Πεδίο" ControlToValidate="tb_password"></asp:RequiredFieldValidator></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Επαλήθευση Password:</td><td class="fieldmain"><asp:TextBox ID="tb_passwordagain" TextMode="Password" runat="server"  CssClass="fieldtb"></asp:TextBox></td><td>
        <asp:CompareValidator ID="CompareValidator1" runat="server" 
            ErrorMessage="Τα δυο passwords δεν είναι ίδια" ControlToCompare="tb_password" 
            ControlToValidate="tb_passwordagain"></asp:CompareValidator></td></tr>
</table>
</td></tr>

<tr><td class="headerrow">ΣΤΟΙΧΕΙΑ ΧΡΗΣΤΗ</td></tr>
<tr><td align="left">
<table cellpadding="0" cellspacing="0" width="100%">
    <tr><td style="width:160px" class="fieldtitle">Όνομα:</td><td class="fieldmain">
        <asp:TextBox ID="tb_firstname" runat="server" CssClass="fieldtb"></asp:TextBox></td><td></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Επώνυμο:</td><td class="fieldmain">
        <asp:TextBox ID="tb_lastname" runat="server" CssClass="fieldtb"></asp:TextBox></td><td></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Διεύθυνση:</td><td class="fieldmain">
        <asp:TextBox ID="tb_address" runat="server" CssClass="fieldtb"></asp:TextBox></td><td></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Τ.Κ.:</td><td class="fieldmain">
        <asp:TextBox ID="tb_tk" runat="server" CssClass="fieldtb"></asp:TextBox></td><td></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Πόλη:</td><td class="fieldmain">
        <asp:TextBox ID="tb_city" runat="server" CssClass="fieldtb"></asp:TextBox></td><td></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Χώρα:</td><td class="fieldmain">
        <asp:DropDownList ID="DropDownList1" runat="server" 
            DataSourceID="SqlDataSource1" DataTextField="plc_name" DataValueField="plc_id">
        </asp:DropDownList>
        </td><td></td></tr>
    <tr><td style="width:160px" class="fieldtitle">Τηλέφωνο:</td><td class="fieldmain">
        <asp:TextBox ID="tb_phone" runat="server" CssClass="fieldtb"></asp:TextBox></td><td></td></tr>
</table>
</td></tr>
<tr><td class="headerrow">ΑΠΟΔΟΧΗ</td></tr>
<tr><td align="left">
<table cellpadding="0" cellspacing="0" width="100%">
    <tr><td class="fieldtitle">Αποδοχή όρων:&nbsp;<asp:CheckBox ID="chb_accept" runat="server" />&nbsp;&nbsp;<asp:CustomValidator
            ID="CustomValidator1" runat="server" 
            ErrorMessage="Η αποδοχή των όρων είναι υποχρεωτική" 
            ClientValidationFunction="checkTerms"></asp:CustomValidator></td></tr>
    <tr><td class="fieldtitle">Επιθυμώ να λαμβάνω ενημερωτικά e-mail από την υπηρεσία LComix:&nbsp;<asp:CheckBox ID="chb_news" runat="server" /></td></tr>
</table>
</td></tr>
<tr><td class="headerrow" align="center">
    <a href="#" onclick="createProfileAjax();" class="detailsbutton" style="text-align:center">Αποθήκευση</a>
    </td></tr>
        

</table>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:mainconectionstring %>" 
        SelectCommand="SELECT [plc_id], [plc_name] FROM [PLACES] ORDER BY [plc_order]">
    </asp:SqlDataSource>

</asp:Content>
